<script type="text/ecmascript-6">
  import Navbar from '../../components/base/navbar.vue';
  export default{
    name:"registration_activity",
    components:{
      Navbar
    },
    data(){
        return {
          page: 0,
          hasMore: true,
          myID: this.$route.params.id,
          isList: false,
          city: '',
          custom_option: {
            tips: {
              downEnd: '没有更多活动了'
            }
          },
          heights:"100%"
        }
    },
    methods:{
       loadMore(){
//          console.log(1);
         if(!this.hasMore){
             return this.$emit("done");
//             return this.$refs.pulldown.onLoadOff();
         }
         let page =this.page +1;
         this.$store.dispatch("queryActivityList",{id:this.myID,page:page});

       },
      jump_detail(id) {
        this.$router.push({ name: 'activity_detail', params: {entrance: 'registration', id: id} });
      },
        refresh(){
          this.$store.dispatch("queryActivityList",{id:this.myID});
        },
        pageLoaded(success,page){
          if (success) {
            this.hasMore = page.current_page < page.total_pages;
            this.page = page.current_page;
          }
          this.$emit("done");
        },
       done(){
         this.$nextTick(() => {
           this.$refs.pulldown.onLoadOff();
         })
       }
    },
    created(){
        EventBus.$on("page-loaded",this.pageLoaded);
        this.$on("done",this.done);
        this.$store.dispatch("queryActivityList",{id:this.myID});
    },
    mounted(){

    },
    beforeDetory(){
      EventBus.$off("page-loaded");
    },
    computed:{
      list:{
        get(){
           return this.$store.getters.getActivityList
        }
      }
    }
  }
</script>
